package com.xyck.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xyck.common.annotation.Log;
import com.xyck.common.core.controller.BaseController;
import com.xyck.common.core.domain.AjaxResult;
import com.xyck.common.enums.BusinessType;
import com.xyck.manage.domain.ArticleSort;
import com.xyck.manage.service.IArticleSortService;
import com.xyck.common.utils.poi.ExcelUtil;
import com.xyck.common.core.page.TableDataInfo;

/**
 * 物品分类管理Controller
 * 
 * @author 星野漫游
 * @date 2024-07-07
 */
@RestController
@RequestMapping("/manage/sort")
public class ArticleSortController extends BaseController
{
    @Autowired
    private IArticleSortService articleSortService;

    /**
     * 查询物品分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sort:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArticleSort articleSort)
    {
        startPage();
        List<ArticleSort> list = articleSortService.selectArticleSortList(articleSort);
        return getDataTable(list);
    }

    /**
     * 导出物品分类管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:sort:export')")
    @Log(title = "物品分类管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArticleSort articleSort)
    {
        List<ArticleSort> list = articleSortService.selectArticleSortList(articleSort);
        ExcelUtil<ArticleSort> util = new ExcelUtil<ArticleSort>(ArticleSort.class);
        util.exportExcel(response, list, "物品分类管理数据");
    }

    /**
     * 获取物品分类管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:sort:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(articleSortService.selectArticleSortById(id));
    }

    /**
     * 新增物品分类管理
     */
    @PreAuthorize("@ss.hasPermi('manage:sort:add')")
    @Log(title = "物品分类管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArticleSort articleSort)
    {
        return toAjax(articleSortService.insertArticleSort(articleSort));
    }

    /**
     * 修改物品分类管理
     */
    @PreAuthorize("@ss.hasPermi('manage:sort:edit')")
    @Log(title = "物品分类管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArticleSort articleSort)
    {
        return toAjax(articleSortService.updateArticleSort(articleSort));
    }

    /**
     * 删除物品分类管理
     */
    @PreAuthorize("@ss.hasPermi('manage:sort:remove')")
    @Log(title = "物品分类管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(articleSortService.deleteArticleSortByIds(ids));
    }
}
